package com.example.food03.bool;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public final class MySqlConnection {
    public static Statement stmt;
    public MySqlConnection() {
        try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection cn= DriverManager.getConnection("jdbc:mysql://192.168.43.126:3306/mvc?useUnicode=true&characterEncodeing=UTF-8&useSSL=false&serverTimezone=GMT&allowPublicKeyRetrieval=true","local","123456");
            //Class.forName(driver).newInstance();
            //  Connection conn=(Connection) DriverManager.getConnection(url,user,password);
            stmt =  cn.createStatement();
        } catch (ClassNotFoundException e) {
            System.out.println("连接数据库失败");
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

